//
//  ZZCReadCollectionViewCell.m
//  B段项目
//
//  Created by dllo on 15/12/24.
//  Copyright © 2015年 张智超. All rights reserved.
//

#import "ZZCReadCollectionViewCell.h"

@interface ZZCReadCollectionViewCell ()

@property (nonatomic, retain)UIImageView *image;
@property (nonatomic, retain)UILabel *nameLabel;
@property (nonatomic, retain)UILabel *ennameLabel;

@end

@implementation ZZCReadCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews
{
    self.image = [[UIImageView alloc] initWithFrame:self.bounds];
    [self.contentView addSubview:self.image];
    
    UIImageView *image = [[UIImageView alloc] initWithFrame:self.bounds];
    image.image = [UIImage imageNamed:@"jianbian.jpg"];
    image.alpha = 0.4;
    [self.image addSubview:image];
    
    self.nameLabel = [[UILabel alloc] init];
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, self.image.frame.size.height * 0.8, self.bounds.size.width, self.image.frame.size.height* 0.2)];
    self.nameLabel.textColor = [UIColor whiteColor];
    [self.image addSubview:self.nameLabel];
//    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    
//        make.left.mas_equalTo(5);
//        make.bottom.equalTo(self.mas_bottom).offset(-5);
//        make.width.equalTo(self.mas_width).multipliedBy(0.3);
//        make.height.equalTo(self.image.mas_height).multipliedBy(0.2);
//    }];
    
    
    self.ennameLabel = [[UILabel alloc] init];
    self.ennameLabel.textColor = [UIColor whiteColor];
    self.ennameLabel.font = [UIFont systemFontOfSize:10];
    [self.image addSubview:self.ennameLabel];
//    [self.ennameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.left.equalTo(self.nameLabel.mas_right).offset(5);
//        make.bottom.equalTo(self.nameLabel.mas_bottom);
//        make.width.mas_equalTo(50);
//        make.height.mas_equalTo(10);
//    }];
}

- (void)setReadList:(ZZCReadModel *)readList
{
    _readList = readList;
    
    [self.image sd_setImageWithURL:[NSURL URLWithString:self.readList.coverimg] placeholderImage:[UIImage imageNamed:@"zhanwei.jpg"]];
    self.nameLabel.text = self.readList.name;
//    self.nameLabel.numberOfLines = 0;
    [self.nameLabel sizeToFit];
    self.ennameLabel.frame = CGRectMake(self.nameLabel.frame.origin.x + self.nameLabel.frame.size.width + self.contentView.frame.size.width / 128, self.nameLabel.frame.origin.y + self.nameLabel.frame.size.height / 3, 50, 10);
//    [self.ennameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.left.equalTo(self.nameLabel.mas_right).offset(5);
//        make.bottom.equalTo(self.nameLabel.mas_bottom);
//        make.width.mas_equalTo(50);
//        make.height.mas_equalTo(10);
//    }];
    
    self.ennameLabel.text = self.readList.enname;
//    self.ennameLabel.numberOfLines = 0;
    [self.ennameLabel sizeToFit];
}


@end
